package com.tyqx.hashchainbiz.service.impl;

import com.tyqx.hashchainbean.module.SysUser;
import com.tyqx.hashchainbean.test.BaiWanTest;
import com.tyqx.hashchainbean.test.BaiWanTestVO;
import com.tyqx.hashchainbean.vo.SysPermissionVO;
import com.tyqx.hashchainbiz.service.BaiWanTestService;
import com.tyqx.hashchaindao.mapper.BaiWanTestMapper;
import hashchainutil.common.BackendPage;
import hashchainutil.common.Constants;
import hashchainutil.common.EmptyUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service("baiWanTestService")
public class BaiWanTestServiceImpl implements BaiWanTestService {

    @Resource
    private BaiWanTestMapper baiWanTestMapper;

    @Override
    public Integer insertBatch(List<BaiWanTest> baiWanTestList) {
        return baiWanTestMapper.insertBatch(baiWanTestList);
    }

    @Override
    public BackendPage<List<BaiWanTest>> getBaiWanTestList(Map<String, Object> param, Integer pageNo, Integer pageSize) {
        Integer total = baiWanTestMapper.getCount();
        pageNo = EmptyUtils.isEmpty(pageNo) ? Constants.DEFAULT_PAGE_NO : pageNo;
        pageSize = EmptyUtils.isEmpty(pageSize) ? Constants.DEFAULT_PAGE_SIZE : pageSize;
        param.put("beginPos", (pageNo - 1) * pageSize);
        param.put("pageSize", pageSize);
        List<BaiWanTest> baiWanTestList = baiWanTestMapper.getBaiWanTestList(param);
        BackendPage page = new BackendPage(total, baiWanTestList);
        return page;
    }

}
